<?php

ini_set('max_execution_time', '12000');
ini_set('memory_limit', '512M');

require("core/functions.php");

$File = str_replace('//', '/', $_SERVER['DOCUMENT_ROOT']."/".$_GET['file']);
if(file_exists($File))
{
	if(!$_GET['name']) {
		$data = explode("/", $File);
		$name = array_pop($data);
	}
	else {
		$fileParts  = pathinfo($File);
		$name = str_replace(" ", "_", translite(urldecode($_GET['name']))).".".$fileParts["extension"];
	}
	header("Content-Disposition: attachment; filename=".$name);
	header("Content-type: application/octet-stream");
	exit(file_get_contents($File));
}
else {
	exit('<h1>Not Found!</h1>');
}
?>